﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>我的日报</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="/CSS/Base/BaseClass.css?cssver=4" rel="stylesheet" type="text/css" />
    <style type="text/css">
        html, body {
            overflow: hidden;
        }

        ul {
            list-style: none;
            padding-left: 30px;
            font-size: 16px;
        }

            ul li {
                margin-bottom: 5px;
            }

                ul li .spanli:hover {
                    background-color: bisque;
                    cursor: pointer;
                }

            ul .spanwz {
                margin-left: 2px;
                padding: 2px;
            }

            ul .fa {
                cursor: pointer;
                color: crimson;
            }

        .panel {
            border-radius: 0;
        }

        .treefile {
            width: 20px;
            height: 18px;
            color: #1B9AF7;
        }

        dl {
            margin-bottom: 10px;
        }
    </style>
</head>
<body ms-controller="USUERGZRZLIST">
    <script type="avalon" id="tmpl">
        <ul>
            <li ms-repeat-branch="branch.SubBranch"><span class="spanli" ms-click="folderclick(branch,this)"> <i class="iconfont icon-bumenshezhi" style="color:#1B9AF7;"></i><span class="spanwz">{{branch.BranchName}}</span></span><div ms-include="'tmpl'" style="display:none"></div></li>
            <li ms-repeat-user="branch.SubUsers" ms-click="fnqueryuser(user)" class="sel">
                <span class="spanli">
                    <i class=" treefile iconfont icon-ren"></i>
                    <span class="spanwz">{{user.UserRealName}}</span>
                </span>
            </li>
        </ul>
    </script>
    <div class="container-fluid maindiv" style="margin-top: 20px" id="dvContent">
        <div style="width:140px;position:absolute">
            <ul class="list-group text-center  leftmenu ">
                <li class="list-group-item" ms-class-1="sel:menutype==''" ms-click="selmenu('')">
                    <div>
                        <i class="iconfont icon-838ribao hvr-grow"></i>
                        {{UserCount}}
                    </div>
                    <div>个人日报</div>
                </li>
                <li class="list-group-item " ms-class-1="sel:menutype=='-1'" style="border-top:0;margin-top:2px" ms-click="selmenu('-1')">
                    <div>
                        <i class="iconfont icon-bumen hvr-grow "></i>{{TotalCount}}
                    </div>
                    <div>部门日报</div>

                </li>
            </ul>
            <div class="panel panel-default" ms-if="menutype=='-1'" style="margin-left:2px">
                <div class=" panel-body" style="padding:5px 0 5px 0">
                    <ul style="padding-left: 10px;margin-top:10px;">
                        <li ms-repeat-branch="userlist.SubBranch">
                            <span class="spanli" ms-click="folderclick(branch,this)"><i class="iconfont icon-bumenshezhi" style="color:#1B9AF7;"></i><span class="spanwz">{{branch.BranchName}}</span></span>
                            <div ms-include="'tmpl'" class="divuser" style="display: none"></div>
                        </li>
                        <li ms-repeat-user="userlist.SubUsers" ms-click="fnqueryuser(user)">
                            <span class="spanli">
                                <i class=" treefile iconfont icon-ren"></i>
                                <span class="spanwz">{{user.UserRealName}}</span>
                            </span>
                        </li>
                    </ul>
                </div>
            </div>

        </div>
        <div class="row contentdv" style="margin-left:141px">
            <div class="col-xs-12">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-xs-9">
                                <div class="input-group">
                                    <div class="input-group-addon">查询条件</div>
                                    <select class="form-control" ms-duplex="GZtype" style="width:30%" ms-change="GetGZDataList()">
                                        <option value="">全部日报类型</option>
                                        <option ms-repeat-item="GZTypeData" ms-attr-val="item.TypeNO" ms-change="GetGZDataList()">{{item.TypeNO}}</option>
                                    </select>
                                    <input id="tbSearch" class="form-control" style="width:70%" type="text" ms-duplex="content" placeholder="输入日报内容查询" />
                                    <span class="input-group-btn">
                                        <button class="btn btn-info" ms-click="GetGZDataList()">查询</button>
                                    </span>
                                </div>
                            </div>
                            <div class="col-xs-3 text-right">
                                <a href="#" id="btADD" ms-click="AddGZRZ()" style=" height: 34px;line-height: 34px;" class="button button-primary">添加日报</a>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="panel panel-default " ms-repeat-item="CommonData">
                    <span class="label label-info deldata" ms-if="item.CRUser==username" ms-click="EDITGZRZ(item.ID)" style="right:50px;">修改</span>
                    <span class="label label-danger deldata" ms-if="item.CRUser==username" ms-click="DELGZRZ(item)">删除</span>
                    <div class="panel-heading hidPan" style="    BACKGROUND-COLOR: WHITE;border-bottom: 0;">
                        <span class="panel-title">
                            &nbsp;[{{item.LeiBie}}]{{item.RBDate|date("yyyy-MM-dd")}}[by{{ComFunJS.convertuser(item.CRUser) }}]  <span class="label label-danger" style="border-radius: 25PX;" ms-if="ComFunJS.daysBetween(ComFunJS.getnowdate('yyyy-mm-dd'), item.CRDate.substring(0,10)) == 0||ComFunJS.daysBetween(ComFunJS.getnowdate('yyyy-mm-dd'), item.CRDate.substring(0,10)) == -1">新!</span>             <!--ms-if-->
                        </span>
                    </div>
                    <div class="panel-body" style="margin-bottom:0;">
                        <blockquote style="margin-bottom:0">
                            <p ms-html="item.RBContent"></p>
                            <footer>日报内容 </footer>
                            <p ms-html="item.RBWCQK" ms-if="item.RBWCQK!=''"></p>
                            <footer ms-if="item.RBWCQK!=''">完成情况 </footer>
                        </blockquote>
                        <label ms-if="item.FileList.length>0"> 附件：</label><a style="margin-left:10px" ms-repeat-files="item.FileList" target="_blank" download="filename" ms-attr-href="'/View/Common/DownLoadFile.aspx?MD5='+files.FileMD5">{{files.Name+'.'+files.FileExtendName}}</a>
                    </div>
                    <div class="panel-footer" style="overflow: hidden;border-top:0">
                        <div class="chat-widget" style="margin-top: 5PX; margin-bottom: 5px">
                            <ul class="list-unstyled">
                                <li class="by-me Yan-comment" ms-repeat-el="item.PLList">
                                    <div class="avatar" style="float: left">
                                        <img alt="" ms-attr-src="'/Upload/TX/'+el.CRUser+'.jpg'" style="width:65px;height:65px" onerror="javascript: this.src = '/images/TX/default.png'">
                                    </div>
                                    <div class="chat-content">
                                        <div class="chat-meta">{{el.CRUserName}} <span style="float: right"><!--ms-if-->{{el.CRDate|date("MM月dd日 HH:mm")}}</span></div>
                                        {{el.MSGContent}}
                                        <div class="clearfix"></div>
                                    </div>
                                </li>
                            </ul>
                        </div>
                        <div class="input-group">
                            <input class="form-control" type="text" ms-keypress="jptj(event,item,$(this))" placeholder="此处添加批注(按Ctrl+Enter直接提交)" />
                            <span class="input-group-btn">
                                <button type="button" data-loading-text="正在保存..." class="btn  btn-info addTL" autocomplete="off" ms-on-click="AddPL(item,$(this).parent().parent().find('input'))">
                                    添加批注
                                </button>
                            </span>
                        </div>
                    </div>
                </div>
                <!--<button type="button" class="btn btn-default btn-lg btn-block" id="btnmore" ms-click="GetGZDataList()">加载更多</button>-->
            </div>
            <div id="pageDiv" class="text-center"></div>
        </div>
    </div>
    <script src="/Scripts/jquery-1.11.2.min.js"></script>
    <script src="/JqueryPlug/laypage/laypage.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/jquery-migrate-1.1.0.min.js"></script>
    <script src="/Scripts/SZHLCommon.js?jsver=5"></script>
    <script>

        var model = avalon.define({
            $id: "USUERGZRZLIST",
            menutype: "",//菜单类型(0:个人日报.-1:"当前部门日报")
            selmenu: function (val) {
                model.menutype = val;
                model.CommonData.clear();
                model.page = 0;
                model.GetGZDataList()
                model.queryuser = "";
                if (model.menutype == "-1") {
                    $.getJSON('/API/SZHLAPI.ashx?Action=GETUSERTREE', { P1: "1", }, function (resultData) {//获取可以查看日报的人员列表
                        model.userlist = resultData.Result;
                    })
                }
            },//选中菜单事件
            queryuser: "",
            fnqueryuser: function (item) {
                if (item) {
                    model.queryuser = item.UserName;
                    model.CommonData.clear();
                    model.page = 0;
                    model.GetGZDataList();
                }

            },
            username: ComFunJS.getnowuser(),
            userlist: {},
            folderclick: function (item, dom) {
                $(".divuser").hide();
                $(dom).parent().find("div").eq(0).toggle();
            },
            GZtype: "",
            selGZType: "",
            GZTypeData: [],
            CommonData: [],
            TotalCount: 0,
            UserCount: 0,
            selContent: "",
            content: "",
            page: 0,
            AddGZRZ: function () {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=GZRZ", "添加数据", "1000", "");
            },
            GetGZDataList: function () {
                $.getJSON('/API/FTAPI.ashx?Action=GETGZRZLIST', { P1: model.GZtype, p: 1, P2: model.content, b: model.menutype,  QUSER:  "'" + model.queryuser + "'" }, function (resultData) {
                    model.CommonData.clear();
                    model.CommonData = resultData.Result;
                    model.selGZType = model.GZtype;
                    model.selContent = model.content;
                    if (parseInt(resultData.Result1) > 1) {
                        laypage({
                            cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                            pages: parseInt(resultData.Result1), //通过后台拿到的总页数
                            curr: 1, //初始化当前页
                            jump: function (e) { //触发分页后的回调
                                if (model.selGZType != model.GZtype || model.selContent != model.content) {
                                    e.curr = 1;
                                }
                                $.getJSON('/API/FTAPI.ashx?Action=GETGZRZLIST', { P1: model.GZtype, p: e.curr, P2: model.content, b: model.menutype,  QUSER:  "'" + model.queryuser + "'" }, function (resultData) {
                                    model.CommonData.clear();
                                    model.CommonData = resultData.Result;
                                    model.selGZType = model.GZtype;
                                    model.selContent = model.content;
                                })
                            }
                        });
                    }
                })
            },
            GetGZType: function () {
                $.getJSON('/API/FTAPI.ashx?Action=GETCOLUMNLIST', { P1: 7 }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.GZTypeData = resultData.Result;
                        model.GetGZDataList();
                    }
                })
            },
            DELGZRZ: function (item) {
                if (confirm("确定要删除日报么？")) {
                    $.post('/API/FTAPI.ashx?Action=DELGZRZBYID', { "P1": item.ID }, function (result) {
                        result = JSON.parse(result)
                        if (result.ErrorMsg == "") {
                            parent.ComFunJS.winsuccess("删除成功");
                            model.CommonData.remove(item);
                        } else {
                            parent.ComFunJS.winwarning(result.ErrorMsg);
                        }
                    })
                }
            },
            EDITGZRZ: function (ID) {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=GZRZ&FrameName=frameGZRZ&ID=" + ID, "修改数据", "1000", "");
            },
            AddPL: function (item, dom) {
                var plcontent = dom.val();
                if ($.trim(plcontent) == "") {
                    parent.ComFunJS.winwarning("请输入批注内容");
                    return;
                }
                $.post('/API/FTAPI.ashx?Action=ADDCOMENT', { "P1": plcontent, "MsgType": "GZRZ", "MsgLYID": item.ID }, function (result) {
                    var result = $.parseJSON(result);
                    if (result.ErrorMsg == "") {
                        item.PLList.push(result.Result)
                        dom.val("")
                    }
                })
            },
            jptj: function (event, item, dom) {
                if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10)) {
                    model.AddPL(item, dom);
                }
            },
        });
        avalon.ready(function () {
            ComFunJS.initsetajax();
            model.GetGZType();
            $.getJSON('/API/FTAPI.ashx?Action=GETGZRZMENUCOUNT', function (resultData) {
                if (resultData.ErrorMsg == "") {
                    model.TotalCount = resultData.Result == "0" ? "" : resultData.Result;
                    model.UserCount = resultData.Result1 == "0" ? "" : resultData.Result1;
                }
            })
        })

    </script>
</body>
</html>
